Skip to content

Use Microsoft.IO over System.IO#9869

Merged
drewnoakes merged 1 commit intodotnet:mainfrom
drewnoakes:use-microsoft-io
Dec 11, 2025
Merged

Use Microsoft.IO over System.IO#9869
drewnoakes merged 1 commit intodotnet:mainfrom
drewnoakes:use-microsoft-io

Conversation

@drewnoakes
Copy link
Member

@drewnoakes drewnoakes commented Dec 7, 2025

When targeting .NET Framework, some commonly-used System.IO classes have worse performance than in .NET. They are also not null-annotated, which can allow bugs to slip through undetected.

This change uses a global alias across the solution so that Path and Directory types come from the newer Microsoft.IO package/assembly. This gives us a reduction in allocations, access to newer methods (like Path.Join), and correct null annotations.

All other changes here are in response to the use of the newer package, mostly around handling null values correctly.

@drewnoakes drewnoakes requested a review from a team as a code owner December 7, 2025 10:41
When targeting .NET Framework, some commonly-used System.IO classes have
worse performance than in .NET. They are also not null-annotated, which
can allow bugs to slip through undetected.

This change uses a global alias across the solution so that Path and
Directory types come from the newer Microsoft.IO package/assembly. This
gives us a reduction in allocations, access to newer methods (like
Path.Join), and correct null annotations.

All other changes here are in response to the user of the newer package,
mostly around handling null values correctly.
Copy link
Member

@haileymck haileymck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice change!

@drewnoakes drewnoakes merged commit e210909 into dotnet:main Dec 11, 2025
5 checks passed
@drewnoakes drewnoakes deleted the use-microsoft-io branch December 11, 2025 19:53
@dotnet-policy-service dotnet-policy-service bot added this to the 18.3 milestone Dec 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants